package com.cleaningcloud.erp.mapper;

import com.cleaningcloud.erp.domain.ErpSupplierCommodity;
import com.cleaningcloud.erp.domain.vo.ErpSupplierCommodityVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 供应商商品Mapper接口
 *
 * @author cleaningcloud
 * @date 2024-09-26
 */
public interface ErpSupplierCommodityMapper {
    /**
     * 查询供应商商品
     *
     * @param supplierCommodityId 供应商商品主键
     * @return 供应商商品
     */
    ErpSupplierCommodity selectErpSupplierCommodityBySupplierCommodityId(Long supplierCommodityId);

    /**
     * 查询供应商商品列表
     *
     * @param erpSupplierCommodity 供应商商品
     * @return 供应商商品集合
     */
    List<ErpSupplierCommodityVo> selectErpSupplierCommodityList(ErpSupplierCommodity erpSupplierCommodity);

    /**
     * 新增供应商商品
     *
     * @param erpSupplierCommodity 供应商商品
     * @return 结果
     */
    int insertErpSupplierCommodity(ErpSupplierCommodity erpSupplierCommodity);

    /**
     * 修改供应商商品
     *
     * @param erpSupplierCommodity 供应商商品
     * @return 结果
     */
    int updateErpSupplierCommodity(ErpSupplierCommodity erpSupplierCommodity);

    /**
     * 删除供应商商品
     *
     * @param supplierCommodityId 供应商商品主键
     * @return 结果
     */
    int deleteErpSupplierCommodityBySupplierCommodityId(Long supplierCommodityId);

    /**
     * 批量删除供应商商品
     *
     * @param supplierCommodityIds 需要删除的数据主键集合
     * @return 结果
     */
    int deleteErpSupplierCommodityBySupplierCommodityIds(Long[] supplierCommodityIds);


    /**
     * 校验商品编号是否唯一
     *
     * @param supplierCommodityNo 商品编号
     * @return 结果
     */
    @Select("select count(1) from erp_supplier_commodity a where supplier_commodity_no = #{supplierCommodityNo} and supplier_id = #{supplierId}")
    int checkNoUnique(@Param("supplierCommodityNo") String supplierCommodityNo, @Param("supplierId") Long supplierId);


    /**
     * 根据供应商商品编码查询商品
     *
     * @return
     */
    ErpSupplierCommodity selectErpSupplierCommodityBySupplierCommodityNo(@Param("supplierCommodityNo") String supplierCommodityNo, @Param("supplierId") Long supplierId);
}
